﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>材料管理</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
		<!--<style>
			.mui-table h4,
			.mui-table h5,
			.mui-table .mui-h5,
			.mui-table .mui-h6,
			.mui-table p {
				margin-top: 0;
			}
			
			.mui-table h4 {
				line-height: 21px;
				font-weight: 500;
			}
			
			.mui-table .oa-icon {
				position: absolute;
				right: 0;
				bottom: 0;
			}
			
			.mui-table .oa-icon-star-filled {
				color: #f14e41;
			}
			
			.title {
				margin: 20px 15px 10px;
				color: #6d6d72;
				font-size: 15px;
			}
		</style>-->
	</head>

	<body>

		<div class="mui-input-row mui-search">
			<input type="search" id="searchInput" onkeyup="enterSearch(event)" class="mui-input-clear" placeholder="输入查询条件">
			<input id="value" hidden="true" />
			<input id="proid" hidden="true" />
		</div>
		<div class="list-t-wrap">
			<div id="pullrefresh" class="mui-scroll-wrapper">
				<div class="mui-scroll" id="mui-table-view">
					<!--
                    	作者：cumtwf@126.com
                    	时间：2016-10-15
                    	描述：放内容
                    -->
				</div>
			</div>
		</div>

	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/wf.js"></script>
	<script src="../js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/tools/template.js" type="text/javascript" charset="utf-8"></script>

	<link rel="stylesheet" type="text/css" href="../css/app.css" />
	<link rel="stylesheet" type="text/css" href="../css/base2.css" />
	<link rel="stylesheet" type="text/css" href="../css/Monitor.css" />
	<link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
	<script type="text/javascript">
		mui.init({
			gestureConfig: {
				longtap: true
			},
			pullRefresh: {
				container: '#pullrefresh',
				down: {
					callback: pulldownRefresh
				},
				up: {
					contentrefresh: '正在加载...',
					callback: pullupRefresh
				}
			}

		});
		var pagesize = 8;
		var page = 1;
		var TotalPage = 1;
		var strWhere = "";
		mui.plusReady(function() {
			var self = plus.webview.currentWebview();
			var username = self.username;
			var userid = self.userid;
			var proid = self.proid;
			var value = self.value;
			document.getElementById("value").value = value;
			document.getElementById("proid").value = proid;
			//document.getElementById("username").value=username;
			//----------------单击事件------------------
			mui("#mui-table-view").on("tap", ".content_box", function() {
//				var id =id;
				var id = this.getAttribute("id");
				mui.openWindow({
					url: 'matupdatedetail.html',
					id: 'matupdatedetail',
					extras: {
						proid: proid,
						username: username,
						mid: id,
						value: value
					}
				});
			})
		});

		/**
		 * 下拉刷新具体业务实现
		 */
		function pulldownRefresh() {
			setTimeout(function() {
				pagesize = 8;
				page = 1;
				TotalPage = 1;
//				var table = document.body.querySelector('.mui-table-view');
//				table.innerHTML = "";
				$("#mui-table-view").empty();
				mui('#pullrefresh').pullRefresh().endPullupToRefresh((page > TotalPage));
				loaddata(strWhere, page++, pagesize);
				mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
			}, 1500);
		}
		/**
		 * 上拉加载具体业务实现
		 */
		function pullupRefresh() {
			setTimeout(function() {
				mui('#pullrefresh').pullRefresh().endPullupToRefresh((page > TotalPage)); //参数为true代表没有更多数据了。
				// 加载更多的内容到列表中
				if(page <= TotalPage) {
					loaddata(strWhere, page++, pagesize);
				}
			}, 1500);
		}
		if(mui.os.plus) {
			mui.plusReady(function() {
				setTimeout(function() {
					mui('#pullrefresh').pullRefresh().pullupLoading();
				}, 1000);

			});
		} else {
			mui.ready(function() {
				mui('#pullrefresh').pullRefresh().pullupLoading();
			});
		}

		function loaddata(strWhere, page, pagesize) {
			var value = document.getElementById("value").value;
			strWhere = "PID=" + document.getElementById("proid").value;
			plus.nativeUI.showWaiting();
			wf.ajax("Material/MaterialList", {
				traditional: true,
				type: "get",
				data: {
					"value": value,
					"strWhere": strWhere,
					"page": page,
					"pagesize": pagesize,
					"orderby": "MID"
				}, //
				dataType: "json",
				success: function(resule) {
					plus.nativeUI.closeWaiting();
					if(resule.Code == "20000") {
						var obj = JSON.parse(resule.Data);

						var data = {
							data: obj.DataList,
							url: wf.server_Domain
						};

						$("#mui-table-view").append(template('tempList', data));

					} else {
						plus.nativeUI.closeWaiting();
						mui.toast(resule.Msg);
					}
				}
			});
		}

		function enterSearch(e) {
			if(e.keyCode == 13) {
				document.body.querySelector('#searchInput').blur();
				setTimeout(function() {
					var inputstr = document.body.querySelector('#searchInput').value;
					pagesize = 8;
					page = 1;
					TotalPage = 1;
					strWhere = "MName like '%" + inputstr + "%'";
					var table = document.body.querySelector('.mui-table-view');
					table.innerHTML = "";
					//mui('#pullrefresh').pullRefresh().endPullupToRefresh((page>TotalPage));
					loaddata(strWhere, page++, pagesize);
					//mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
				}, 1500);
			}
		}
	</script>

	<script id="tempList" type="text/html">
		<%for(var i=0;i<data.length;i++){%>
		<div class="content_box" id="<%=data[i].MID%>">
			<img class="image Head_portrait" src="<%=url%>FileUpload/ReadPic?name=User_<%=data[i].CreatePeople%>"" />
			<p>
				<span class="xinghao">
						材料名称：<%=data[i].MName%></span><br/>
				<span class="date"> 材料描述:
								<%if(data[i].MDes!= ""){%>
									<%=data[i].MDes%>
								<%}else{%>
									暂无信息
								<%}%>
							</span><br/>
				<span class="date"> 审核状态：
								<%if(data[i].AuditStatus==0){%>
									待审核
								<%}else if(data[i].AuditStatus==2){%>
									已审核通过
								<%}else if(data[i].AuditStatus==3){%>
									审核不通过
								<%}%>
								
							</span><br/>
				<span class="gongzuo">创建人：
								<%if(data[i].CreatePeople != ""){%>
									<%=data[i].CreatePeople%>
								<%}else{%>
									暂无信息
								<%}%>
							</span>
			</p>
			
		</div>
		<div class="clear"></div>
		
		<div class="Division"></div>
		
		
		
		<%}%>

	</script>

</html>